package com.whsxt.filter;


import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
import com.alibaba.fastjson.JSON;
import com.whsxt.common.CodeMsg;
import com.whsxt.common.ResultData;

public class ShiroLoginFilter extends FormAuthenticationFilter{
	//用户没有登录就会调用这个方法
	@Override
	protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
		System.out.println("未登录");
		HttpServletResponse resp =  (HttpServletResponse) response;
		ResultData rd = new ResultData(CodeMsg.NOT_LOGIN);
		resp.setCharacterEncoding("UTF-8");
		resp.setContentType("application/json");
		resp.getWriter().write(JSON.toJSONString(rd));
		return false;
	}

	
	
}
